
#include <listener.h>

typedef struct Node {
	int fd;
	struct Node *head;
	struct Node *tail;
} Node;

typedef struct Queue {
	rp_mutex_t mutex;
	rp_sem_t sem;
	int qlength;
	Node *head;
	Node *tail;
} Queue;

Err rp_queue_init(Queue *queue);
void rp_queue_finalize(Queue *queue);
Err rp_queue_put(Queue *queue, int fd);
int rp_queue_get(Queue *queue);

void rp_rindexd_listener(int fd, short event, void *arg)
{
	static char fname[] = "rp_rindexd_listener";
	static char msg[] = "fatal message";
	Err err;
	static Request request;
	static int clifd;
	static struct sockaddr_in cliaddr;
	static socklen_t clilength;
	FLOG_IN(fname);

	memset(&cliaddr, 0, sizeof(struct sockaddr_in));
	clilength = 0;
	/*	accept the tcp connection   */
	if (!(clifd = rp_comm_accept(fd, &cliaddr, &clilength)))	
	{
		rp_log(LOG_ERROR, fname, "No heartbeat connection is setup.");
		return;
	}

	err = rp_queue_put(&(global.q_req), fd);
	err = rp_sem_post(&global.q_req.sem);

	FLOG_OUT(fname);
}



